package aino;

public class Stack {
    int type;
    String cls;
    String value;
    String value2;
    int size;
    final static int INT    = 1;
    final static int REF    = 2;
    final static int CONST  = 3;
    final static int ADDR   = 4;
    final static int TMP    = 5;
    final static int ACC    = 6;
    final static int STRING = 7;
    static String typestrings[] = {"", "INT", "REF", "CONST", "ADDR", "TMP", "ACC", "STRING"};

    public Stack() {
		type = 0;
		cls = null;
		value = null;
		value2 = null;
		size = 0;
    }

    public Stack(Stack s) {
		type = s.type;
		if (s.cls != null) cls = new String(s.cls);
		value = new String(s.value);
		value2 = null;
		if (s.value2 != null) value2 = new String(s.value2);
		size = s.size;
    }

    public Stack(int typ, String val) {
		type = typ;
		cls = null;
		value = val;
		value2 = null;
		size = 1;
    }

    public Stack(int typ, String val, int len) {
		type = typ;
		cls = null;
		if (typ == ADDR && len == 2) {
		    value = val+"+1";
		    value2 = val;
		} else {
		    value = val;
		    value2 = null;
		}
		size = len;
    }

    public Stack(int typ, String val, String val2) {
		type = typ;
		cls = null;
		value = val;
		value2 = val2;
		size = 2;
    }

    public String getTypeString() {
		if (type < 1) return null;
		if (type > 7) return null;
		return typestrings[type];
    }
}
